﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;

namespace Log4netAppder
{

    class Program
    {
        static void Main(string[] args)
        {
            //[assembly:log4net.Config.DOMConfigurator(ConfigFile="log4net.config",Watch=true)]
//#if DEBUG
            System.IO.FileInfo fi = new System.IO.FileInfo("../Log4Net.config");
//#else
//            System.IO.FileInfo fi = new System.IO.FileInfo("Log4Net.config");
//#endif
            log4net.Config.XmlConfigurator.Configure(fi);
            //log4net.ILog log = log4net.LogManager.GetLogger(typeof(Program));
            //string id = Thread.CurrentThread.ManagedThreadId.ToString();
            string id =Process.GetCurrentProcess().Id.ToString();
            string loggerName = id + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType;
            log4net.ILog log = log4net.LogManager.GetLogger(loggerName);
            string str = "";
            //Console.WriteLine("按回车启动");
            //Console.ReadLine();
            System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch();
            stopwatch.Start();
            for (int i = 0; i <= 1;i++ )
            {
                //stopwatch.Reset();
                str = id + "---" + i.ToString("00000000");
                Console.WriteLine(str);
                str +=  "--国开建第二艘航母的传闻由来已久log4net.LogManager.GetLogger(typeof(Program))";
                //log = log4net.LogManager.GetLogger(typeof(Program));
                log.Debug(str);
                //log.Logger.Repository.Shutdown();
                //stopwatch.Stop();
                //Thread.Sleep(1000);                    //停一秒
                System.Threading.Thread.CurrentThread.Join(50);
                
                //log.Info(i.ToString("000000"));
            }

            //log4net.LogManager.Shutdown();
            stopwatch.Stop();
            Console.WriteLine(stopwatch.ElapsedTicks);
            Console.WriteLine("完毕!!!!!!!");
            Console.WriteLine("smtp mail");
            Exception ex = new Exception("这个是个错误日志!!!!!!!");
            log.Error("测试错误！",ex);
            Console.WriteLine(ex.Message);
            Console.WriteLine("OK");
            System.Threading.Thread.CurrentThread.Join(5000);
            //Console.ReadLine();
        }
    }
}
